home *** CD-ROM | disk | FTP | other *** search
Wrap
; Include Version:1.66 (17 July 2006) #include-once #include <Array.au3> #include <StatusBarConstants.au3> #include <WindowsConstants.au3> ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.1.1++ ; Language: English ; Description: Functions that assist with the Statusbar control ; ; ------------------------------------------------------------------------------ ;=== Globals Global $debug = True Global Const $LowOrder = 0xFFFF ;=== End Globals ;=== function list ;=============================================================================== ;_GUICtrlStatusBarCreate ;_GUICtrlStatusBarGetBorders ;_GUICtrlStatusBarGetIcon ;_GUICtrlStatusBarGetParts ;_GUICtrlStatusBarGetRect ;_GUICtrlStatusBarGetText ;_GUICtrlStatusBarGetTextLength ;_GUICtrlStatusBarGetTip ;_GUICtrlStatusBarGetUnicode ;_GUICtrlStatusBarResize ;_GUICtrlStatusBarSetBKColor ;_GUICtrlStatusBarSetIcon ;_GUICtrlStatusBarSetMinHeight ;_GUICtrlStatusBarSetSimple ;_GUICtrlStatusBarSetText ;_GUICtrlStatusBarSetTip ;_GUICtrlStatusBarSetUnicode ;**********Helper************** ;_GUICtrlStatusBarSetParts ;_CreateStructFromArray ;********** ToDo ************** ;_GUICtrlStatusBarSetExtendedStyle ;=============================================================================== ; ; Description: _GUICtrlStatusBarCreate ; Parameter(s): $h_Gui - Handle to parent window ; $a_PanelWidth - width of panel or panels (for more than 1 panel pass in zero based array) ; $s_PanelText - text of panel or panels (for more than 1 panel pass in zero based array) ; $v_styles - styles to apply to the status bar (Optional) for multiple styles bitor them. ; Requirement: ; Return Value(s): Returns hWhnd if successful, or 0 with error set to 1 otherwise. ; User CallTip: _GUICtrlStatusBarCreate($h_Gui, $a_PanelWidth, $s_PanelText[, $v_styles = ""]) Creates Statusbar. (required: <GuiStatusBar.au3>) ; Author(s): rysiora, JdeB, tonedef, ; gafrost (Gary Frost (custompcs at charter dot net)), Steve Podhajecki <gehossafats at netmdc dot com> ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarCreate($h_Gui, $a_PanelWidth, $s_PanelText, $v_styles = "") Local $a_PW[1], $a_PT[1] If Not IsArray($a_PanelWidth) Then $a_PW[0] = $a_PanelWidth Else $a_PW = $a_PanelWidth EndIf If Not IsArray($a_PT) Then $a_PT[0] = $s_PanelText Else $a_PT = $s_PanelText EndIf If Not IsHWnd($h_Gui) Then $h_Gui = HWnd($h_Gui) Local $hwnd_Bar1, $x Local $style = BitOR($WS_CHILD, $WS_VISIBLE) If @NumParams = 4 Then $style = BitOR($style, $v_styles) $hwnd_Bar1 = DllCall("comctl32.dll", "long", "CreateStatusWindow", "long", $style, "str", "", "hwnd", $h_Gui, "int", 0) If @error Then Return SetError(1,1,0) _GUICtrlStatusBarSetParts($hwnd_Bar1[0], UBound($a_PW), $a_PW) For $x = 0 To UBound($s_PanelText) - 1 _GUICtrlStatusBarSetText($hwnd_Bar1[0], $a_PT[$x], $x) Next Return $hwnd_Bar1[0] EndFunc ;==>_GUICtrlStatusBarCreate ;=============================================================================== ; ; Description: _GUICtrlStatusBarGetBorders ; Parameter(s): $h_StatusBar - Handle to statusbar ; Requirement: ; Return Value(s): Returns zero based array ; 0 - width of the horizontal border ; 1 - width of the vertical border ; 2 - width of the border between rectangles ; or zero otherwise. ; User CallTip: _GUICtrlStatusBarGetBorders($h_StatusBar) Gets width of the borders. (required: <GuiStatusBar.au3>) ; Author(s): gafrost (Gary Frost (custompcs at charter dot net)) ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarGetBorders($h_StatusBar) Local $borders = DllStructCreate("int;int;int") If @error Then Return SetError(@error,@error,0) If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETBORDERS, "int", 0, "ptr", DllStructGetPtr($borders)) If (Not $a_ret[0]) Then $borders = 0 Return SetError(-1,-1,0) Else Local $a_borders[3], $x For $x = 0 To 2 $a_borders[$x] = DllStructGetData($borders, $x + 1) Next $borders = 0 Return $a_borders EndIf EndFunc ;==>_GUICtrlStatusBarGetBorders ;=============================================================================== ; ; Description: _GUICtrlStatusBarGetIcon ; Parameter(s): $h_StatusBar - The Control Id (will be converted to hWnd) ; $i_Panel - The panel to hold the text ; Requirement: ; Return Value(s): return hwnd or zero otherwise. ; User CallTip: _GUICtrlStatusBarGetIcon($h_StatusBar[, $i_Panel=0]) Gets Statusbar panel Icon handle. (required: <GuiStatusBar.au3>) ; Author(s): Steve Podhajecki <gehossafats at netmdc dotcom>, gafrost (Gary Frost (custompcs at charter dot net)) ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarGetIcon($h_StatusBar, $i_Panel) If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) Local $ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETICON, "int", $i_Panel, "int", 0) If IsArray($ret) Then Return $ret[0] EndFunc ;==>_GUICtrlStatusBarGetIcon ;=============================================================================== ; ; Description: _GUICtrlStatusBarGetParts ; Parameter(s): $h_StatusBar - The Control Id (will be converted to hWnd) ; ; Requirement: ; Return Value(s): Returns the number of parts in the window, otherwise zero. ; User CallTip: _GUICtrlStatusBarGetParts($h_StatusBar) Retrieves a count of the parts in a status window. (required: <GuiStatusBar.au3>) ; Author(s): Steve Podhajecki <gehossafats at netmdc dot com>, gafrost (Gary Frost (custompcs at charter dot net)) ; ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarGetParts($h_StatusBar) If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) Local $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETPARTS, "int", 0, "int", 0) If IsArray($ret) Then Return $ret[0] EndFunc ;==>_GUICtrlStatusBarGetParts ;=============================================================================== ; ; Description: _GUICtrlStatusBarGetRect ; Parameter(s): $h_StatusBar - Handle to statusbar ; $i_part - zero based index of panel to retrieve rectangle from ; Requirement: ; Return Value(s): Returns zero based array ; 0 - Left ; 1 - Top ; 2 - Right ; 3 - Bottom ; zero otherwise. ; User CallTip: _GUICtrlStatusBarGetRect($StatusBar, $i_part) Retrieves the bounding rectangle of a part in a status window. (required: <GuiStatusBar.au3>) ; Author(s): gafrost (Gary Frost (custompcs at charter dot net)) ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarGetRect($h_StatusBar, $i_part) ;~ typedef struct _RECT { ;~ LONG left; ;~ LONG top; ;~ LONG right; ;~ LONG bottom; ;~ } RECT, *PRECT; Local $RECT = DllStructCreate("int;int;int;int") If @error Then Return SetError(-1,-1,0) If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETRECT, "int", $i_part, "ptr", DllStructGetPtr($RECT)) If IsArray($a_ret) Then If (Not $a_ret[0]) Then $RECT = 0 Return SetError(-1,-1,0) Else Local $a_rect[4], $x For $x = 0 To 3 $a_rect[$x] = DllStructGetData($RECT, $x + 1) Next $RECT = 0 Return $a_rect EndIf Else $RECT = 0 Return SetError(-1,-1,0) EndIf EndFunc ;==>_GUICtrlStatusBarGetRect ;=============================================================================== ; ; Description: _GUICtrlStatusBarGetText ; Parameter(s): $h_StatusBar - The Control Id (will be converted to hWnd) ; $i_Panel - The panel to retreive the text from ; Requirement: ; Return Value(s): Text from panel ; User CallTip: _GUICtrlStatusBarGetText($h_StatusBar[,$i_Panel=0]) Gets Statusbar Text from a part. (required: <GuiStatusBar.au3>) ; Author(s): tonedef, gafrost (Gary Frost (custompcs at charter dot net)), Steve Podhajecki <gehossafats@netmdc.com> ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarGetText($h_StatusBar, $i_Panel = 0) ;== there is a built in function to use for this. See help documentation Local $v_Ret If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) $v_Ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETTEXT, "int", $i_Panel, "strptr", "") If IsArray($v_Ret) Then Return $v_Ret[4] Else Return SetError(-1,-1,"") EndIf EndFunc ;==>_GUICtrlStatusBarGetText ;=============================================================================== ; ; Description: _GUICtrlStatusBarGetTextLength ; Parameter(s): $h_StatusBar - The Control Id (will be converted to hWnd) ; $i_Panel - Nubmer of the panel to retrieve length from ; ; Requirement: ; Return Value(s): Text Length ; User CallTip: _GUICtrlStatusBarGetTextLength ($h_StatusBar, $i_Panel) Retrieves the length, in characters, of the text from the specified part of a status window. (required: <GuiStatusBar.au3>) ; Author(s): Steve Podhajecki <gehossafats@netmdc.com>, gafrost (Gary Frost (custompcs at charter dot net)) ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarGetTextLength($h_StatusBar, $i_Panel) If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) Local $ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETTEXTLENGTH, "int", $i_Panel, "int", 0) If IsArray($ret) Then Return $ret[0] Else Return SetError(-1,-1,-1) EndIf EndFunc ;==>_GUICtrlStatusBarGetTextLength ;=============================================================================== ; ; Description: _GUICtrlStatusBarGetTip ; Parameter(s): $h_StatusBar - The Control Id (will be converted to hWnd) ; $i_Panel - The panel to retreive the text from ; Requirement: ; Return Value(s): Tip Text, on error empty string and @error is set to 1 ; User CallTip: _GUICtrlStatusBarGetTip($h_StatusBar[, $i_Panel=0]) Gets Statusbar TipText. (required: <GuiStatusBar.au3>) ; Author(s): Steve Podhajecki <gehossafats@netmdc.com>, , gafrost (Gary Frost (custompcs at charter dot net)) ; Note(s): The status bar must be created with the $SBT_TOOLTIPS style to enable ToolTips. ;=============================================================================== Func _GUICtrlStatusBarGetTip($h_StatusBar, $i_Panel = 0) Local $v_Ret, $strBuff, $wParam If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) $strBuff = DllStructCreate("char[255]") $wParam = ((DllStructGetSize($strBuff) * 0x10000) + $i_Panel) $v_Ret = DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETTIPTEXT, _ "long", $wParam, "ptr", DllStructGetPtr($strBuff)) If IsArray($v_Ret) Then Return StringStripWS(DllStructGetData($strBuff, 1), 7);strip leading, trailing, and double ws. Else Return SetError(1,1,"") EndIf EndFunc ;==>_GUICtrlStatusBarGetTip ;=============================================================================== ; ; Description: _GUICtrlStatusBarGetUnicode ; Parameter(s): $h_StatusBar - The Control Id (will be converted to hWnd) ; ; Requirement: ; Return Value(s): If this value is nonzero, the control is using Unicode characters. ; If this value is zero, the control is using ANSI characters ; User CallTip: _GUICtrlStatusBarGetUnicode ($h_StatusBar) Retrieves the Unicode character format flag for the control. (required: <GuiStatusBar.au3>) ; Author(s): gafrost (Gary Frost (custompcs at charter dot net)) ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarGetUnicode($h_StatusBar) If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_GETUNICODEFORMAT, "int", 0, "int", 0) If IsArray($a_ret) Then Return $a_ret[0] Else Return SetError(-1,-1,0) EndIf EndFunc ;==>_GUICtrlStatusBarGetUnicode ;=============================================================================== ; ; Description: _GUICtrlStatusBarResize ; Parameter(s): $h_StatusBar - The Control Id (will be converted to hWnd) ; ; Requirement: ; Return Value(s): If the function succeeds, the return value is nonzero, otherwise zero. ; User CallTip: _GUICtrlStatusBarResize($h_StatusBar) Resize Statusbar. (required: <GuiStatusBar.au3>) ; Author(s): Steve Podhajecki <gehossafats@netmdc.com> ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarResize($h_StatusBar) If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) Local $ret = DllCall("user32.dll", "int", "MoveWindow", "hwnd", $h_StatusBar, "int", 0, "int", 0, "int", 0, "int", 0) If IsArray($ret) Then Return $ret[0] Else Return SetError(-1,-1,0) EndIf EndFunc ;==>_GUICtrlStatusBarResize ;=============================================================================== ; ; Description: _GUICtrlStatusBarSetBKColor ; Parameter(s): $h_StatusBar - Handle to statusbar ; $v_HexRGB - Hex RGB color to set Status Bar background ; Requirement: ; Return Value(s): Returns the previous background color or zero upon failure ; User CallTip: _GUICtrlStatusBarSetBKColor($h_StatusBar, $v_HexRGB) Sets the background color in a status bar. (required: <GuiStatusBar.au3>) ; Author(s): gafrost (Gary Frost (custompcs at charter dot net)) ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarSetBKColor($h_StatusBar, $v_HexRGB) Local $tc = Hex(String($v_HexRGB), 6) Local $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETBKCOLOR, "int", 0, "int", '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2)) If IsArray($ret) Then $tc = Hex(String($ret[0]), 6) Return '0x' & StringMid($tc, 5, 2) & StringMid($tc, 3, 2) & StringMid($tc, 1, 2) Else Return SetError(-1,-1,0) EndIf EndFunc ;==>_GUICtrlStatusBarSetBKColor ;=============================================================================== ; ; Description: _GUICtrlStatusBarSetIcon ; Parameter(s): $h_StatusBar - Handle to statusbar ; $i_part - Nubmer of panel to add icon too ; $s_IconFile - file to extract icon from ; $i_iconID - id of the icon ; Requirement: ; Return Value(s): Returns nonzero if successful, or zero otherwise. ; User CallTip: _GUICtrlStatusBarSetIcon($StatusBar, $i_part, $szIconFile, $iconID) Sets an Icon in the Panel. (required: <GuiStatusBar.au3>) ; Author(s): gafrost (Gary Frost ([email="custompcs at charter dot net"]custompcs at charter dot net[/email])) ; Note(s): To remove the icon from a panel use -1 for $i_iconID ; If using simple status bar then set $i_part to 255 ;=============================================================================== Func _GUICtrlStatusBarSetIcon($h_StatusBar, $i_part, $s_IconFile, $i_iconID) Local $hIcon, $result If $i_part = 255 Then $i_part = -1 If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) If $i_iconID = -1 Then $result = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETICON, "int", $i_part, "hwnd", $i_iconID) If IsArray($result) Then Return $result Else Return SetError(-1,-1,0) EndIf Else $hIcon = DllStructCreate("int") $result = DllCall("shell32.dll", "int", "ExtractIconEx", "str", $s_IconFile, "int", $i_iconID, "hwnd", 0, "ptr", DllStructGetPtr($hIcon), "int", 1) $result = $result[0] If $result > 0 Then $result = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETICON, "int", $i_part, "hwnd", DllStructGetData($hIcon, 1)) EndIf DllCall("user32.dll", "int", "DestroyIcon", "hwnd", DllStructGetPtr($hIcon)) $hIcon = 0 If IsArray($result) Then Return $result Else Return SetError(-1,-1,0) EndIf EndIf EndFunc ;==>_GUICtrlStatusBarSetIcon ;=============================================================================== ; ; Description: _GUICtrlStatusBarSetMinHeight ; Parameter(s): $h_StatusBar - Handle to statusbar ; $i_MinHeight - Minimum height, in pixels, of the window ; Requirement: ; Return Value(s): None ; User CallTip: _GUICtrlStatusBarSetMinHeight($h_StatusBar, $i_MinHeight) Sets the minimum height of a status window's drawing area. (required: <GuiStatusBar.au3>) ; Author(s): gafrost (Gary Frost (custompcs at charter dot net)) ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarSetMinHeight($h_StatusBar, $i_MinHeight) If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETMINHEIGHT, "int", $i_MinHeight, "int", 0) _GUICtrlStatusBarResize($h_StatusBar) EndFunc ;==>_GUICtrlStatusBarSetMinHeight ;=============================================================================== ; ; Description: _GUICtrlStatusBarSetSimple ; Parameter(s): $h_StatusBar - Handle to statusbar ; $b_Simple - Display type flag. ; If this parameter is TRUE, the window displays simple text. (Default) ; If it is FALSE, it displays multiple parts ; Requirement: ; Return Value(s): None ; User CallTip: _GUICtrlStatusBarSetSimple($h_StatusBar[, $b_Simple = True]) Specifies whether a status window displays simple text or displays all window parts. (required: <GuiStatusBar.au3>) ; Author(s): gafrost (Gary Frost (custompcs at charter dot net)) ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarSetSimple($h_StatusBar, $b_Simple = True) If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SIMPLE, "int", $b_Simple, "int", 0) EndFunc ;==>_GUICtrlStatusBarSetSimple ;=============================================================================== ; ; Description: _GUICtrlStatusBarSetText ; Parameter(s): $h_StatusBar - The Control Id (will be converted to hWnd) ; $s_Data - The text to display in the panel ; $i_Panel - The panel to hold the text (Default: 0) ; Requirement: ; Return Value(s): Returns TRUE if successful, or FALSE otherwise. ; User CallTip: _GUICtrlStatusBarSetText($h_StatusBar[, $s_Data = ""[, $i_Panel = 0]]) Sets the text in the specified part of a status window. (required: <GuiStatusBar.au3>) ; Author(s): rysiora, JdeB, tonedef, ; gafrost (Gary Frost (custompcs at charter dot net)) ; Note(s): Set $i_Panel to 255 for simple statusbar ;=============================================================================== Func _GUICtrlStatusBarSetText($h_StatusBar, $s_Data = "", $i_Panel = 0) If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) Local $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETTEXT, "int", $i_Panel, "str", $s_Data) If IsArray($ret) Then Return $ret[0] Else Return SetError(1,1,False) EndIf EndFunc ;==>_GUICtrlStatusBarSetText ;=============================================================================== ; ; Description: _GUICtrlStatusBarSetTip ; Parameter(s): $h_StatusBar - Handle to statusbar ; $i_part - Zero-based index of the part that will receive the ToolTip text ; $s_ToolTip - new ToolTip text ; Requirement: ; Return Value(s): None ; User CallTip: _GUICtrlStatusBarSetTip($h_StatusBar, $i_part, $s_ToolTip) Sets the ToolTip text for a part in a status bar. (required: <GuiStatusBar.au3>) ; Author(s): gafrost (Gary Frost (custompcs at charter dot net)) ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarSetTip($h_StatusBar, $i_part, $s_ToolTip) If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) Local $struct = DllStructCreate("char[" & StringLen($s_ToolTip) + 1 & "]") DllStructSetData($struct, 1, $s_ToolTip) If @error Then Return SetError(@error,@error,0) DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETTIPTEXT, "int", $i_part, "int", DllStructGetPtr($struct)) $struct = 0 EndFunc ;==>_GUICtrlStatusBarSetTip ;=============================================================================== ; ; Description: _GUICtrlStatusBarSetUnicode ; Parameter(s): $h_StatusBar - Handle to statusbar ; $b_Unicode - Determines the character set that is used by the control. ; If this value is TRUE, the control will use Unicode characters. (Default) ; If this value is FALSE, the control will use ANSI characters. ; Requirement: ; Return Value(s): Returns the previous Unicode format flag for the control ; User CallTip: _GUICtrlStatusBarSetUnicode($h_StatusBar[, $b_Unicode = True[) Sets the Unicode character format flag for the control. (required: <GuiStatusBar.au3>) ; Author(s): gafrost (Gary Frost (custompcs at charter dot net)) ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarSetUnicode($h_StatusBar, $b_Unicode = True) If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETUNICODEFORMAT, "int", $b_Unicode, "int", 0) If IsArray($a_ret) Then Return $a_ret[0] Else Return SetError(1,1,False) EndIf EndFunc ;==>_GUICtrlStatusBarSetUnicode ;=============================================================================== ; Helper functions ;=============================================================================== ;=============================================================================== ; ; Description: _GUICtrlStatusBarSetParts ; Parameter(s): $h_StatusBar - The Control Id (will be converted to hWnd) ; $i_Panels - Nubmer of panesl to create ; $i_PanelWidth - width of panel(s) (Default: 100) ; ; Requirement: ; Return Value(s): 1 if successfull, otherwise zero ; User CallTip: _GUICtrlStatusBarSetParts ($h_StatusBar, $i_Panels[, $i_PanelWidth = 100]). (required: <GuiStatusBar.au3>) ; Author(s): tonedef, gafrost (Gary Frost (custompcs at charter dot net)), Steve Podhajecki <gehossafats at netmdc dot com> ; Note(s): ;=============================================================================== Func _GUICtrlStatusBarSetParts($h_StatusBar, $i_Panels, $a_PanelWidth = 100) Local $sta ;~ , $emsg[6] If Not IsHWnd($h_StatusBar) Then $h_StatusBar = HWnd($h_StatusBar) ;=== Set each panel to be same size and assign the last one the remainder If Not IsArray($a_PanelWidth) Then Local $a_PanelWidth[$i_Panels], $panel, $size $size = WinGetClientSize("") For $panel = 0 To $i_Panels - 1 $a_PanelWidth[$panel] = Int(($size[0] / $i_Panels) * $panel + 1) Next $a_PanelWidth[$i_Panels - 1] = -1 EndIf ;== end set sizing $sta = _CreateStuctFromArray($a_PanelWidth, "int") If @error Then Return SetError(1,1,0) ;~ $emsg[0] = "No error." ;~ $emsg[1] = "Unable to use the DLL file." ;~ $emsg[2] = ' unknown "return type".' DllCall("user32.dll", "long", "SendMessage", "hwnd", $h_StatusBar, "int", $SB_SETPARTS, "int", $i_Panels, "ptr", DllStructGetPtr($sta)) If @error Then Return SetError(1,1,0) ;== Sometimes this needs to be called in order to update the status bar. _GUICtrlStatusBarResize($h_StatusBar) $sta = "" Return 1 EndFunc ;==>_GUICtrlStatusBarSetParts ;=============================================================================== ; ; Description: CreateStructFromArray ; Parameter(s): $a_Variable array to create struct with ; $structType, the SINGLE type of struct to create. ; Requirement: ; Return Value(s): ; User CallTip: _CreateStructFromArray ; Author(s): Steve Podhajecki <gehossafats at netmdc dot com> ; Note(s): ;=============================================================================== Func _CreateStuctFromArray($a_Variable, $structType) If Not IsArray($a_Variable) Then Return SetError(1,1,0) Local $a_ctr, $strVar, $struct ;~ , $emsg[6] For $a_ctr = 0 To UBound($a_Variable) - 1 $strVar &= $structType & ";" Next $strVar = StringTrimRight($strVar, 1) ;~ $emsg[0] = "No Error." ;~ $emsg[1] = "Variable passed to DllStructCreate was not a string." ;~ $emsg[2] = "There is an unknown Data Type in the string passed. " ;~ $emsg[3] = "Failed to allocate the memory needed for the struct, or Pointer = 0." ;~ $emsg[4] = "Error allocating memory for the passed string." ;~ $emsg[5] = "" $struct = DllStructCreate($strVar) If @error Then Return SetError(1,1,0) ;~ $emsg[0] = 'No Error. ' ;~ $emsg[1] = 'Struct not a correct struct returned by DllStructCreate.' ;~ $emsg[2] = 'Element value out of range. ' ;~ $emsg[3] = 'index would be outside of the struct.' ;~ $emsg[4] = 'Element data type is unknown' ;~ $emsg[5] = 'index < 0.' For $a_ctr = 0 To UBound($a_Variable) - 1 DllStructSetData($struct, ($a_ctr) + 1, $a_Variable[$a_ctr]) If @error Then Return SetError(1,1,0) Next Return $struct EndFunc ;==>_CreateStuctFromArray